using System;
using System.Collections.Generic;
using System.Text;
using THSLib;
using THSERP.BaseProvider;
using THSERP.BusinessEntities;
namespace THSERP.Modules.Location
{
    public class LocationEntities : ERPModuleEntities
    {
        #region Constants
        public const string cstGELocationsObjectName = "GELocations";
        #endregion

        #region Declare all entities variables
        protected GELocationsInfo _gELocationsObject;
        public THSTreeList lstGELocations;
        public THSList<GELocationsInfo> lstLocations;
        #endregion  

        #region Public Properties
        public GELocationsInfo GELocationsObject
        {
            get
            {
                return _gELocationsObject;
            }
            set
            {
                _gELocationsObject = value;
            }
        }

        public THSTreeList GELocationsList
        {
            get
            {
                return lstGELocations;
            }
            set
            {
                lstGELocations = value;
            }
        }

        public THSList<GELocationsInfo> LocationList
        {
            get
            {
                return lstLocations;
            }
            set
            {
                lstLocations = value;
            }
        }
        #endregion

        #region Constructor
        public LocationEntities()
            : base()
        {

            _gELocationsObject = (GELocationsInfo)new GELocationsController().GetFirstObject();
            if (_gELocationsObject == null)
                _gELocationsObject = new GELocationsInfo();

            lstGELocations = new THSTreeList();
            lstLocations = new THSList<GELocationsInfo>();

        }
        #endregion

        public override void InitModuleEntity()
        {
            base.InitModuleEntity();

            UpdateModuleObjectBindingSource(cstGELocationsObjectName);
        }
        #region Init Main Object,Module Objects functions
        public override void InitModuleObjects()
        {
            ModuleObjects.Add(cstGELocationsObjectName, GELocationsObject);
        }

        public override void InitModuleObjectList()
        {
            lstGELocations = new THSTreeList();
           // lstLocation = new THSList<GELocationsInfo>();
            lstGELocations.InitTHSList(this, string.Empty, LocationModule.cstGELocationsObjectName,THSList<GELocationsInfo>.cstRelationParent);
            lstLocations.InitTHSList(this, string.Empty, LocationModule.cstGELocationsObjectName);
        }

        public override void InitGridControlInTHSList()
        {
            GELocationsList.InitTHSTreeListControl("fld_trlGELocations");
            lstLocations.InitTHSListGridControl();
            
        }
        public override void SetDefaultModuleObjectsList()
        {
            GELocationsList.SetDefaultListAndRefreshTreeListControl();
            LocationList.SetDefaultListAndRefreshGridControl();
        }
        #region Invalidate Module Objects functions
        public override void InvalidateModuleObjects(int iObjectID)
        {
            GELocationsList.InvalidateTreeList(iObjectID);
            lstLocations.Invalidate(iObjectID);
        }
        #endregion
        #endregion
    }
}
